{include file="public/header" /}
<link rel="stylesheet" href="/static/admin/css/base.css" media="all">
<style>
	html {
		background-color: #f2f2f2 !important;
	}
	.layuiadmin-card-header-auto{
		padding: 10px !important;
	}
</style>
<body>
<div class="layui-fluid layui-anim layui-anim-upbit">
	<div class="layui-card">
		<div class="layui-form layui-card-header layuiadmin-card-header-auto">
			<div class="layui-form-item">
				<!--				<div class="nav">-->
				<!--					<span style=""><i class="layui-icon"></i> {$nav.s_nav}</span>-->
				<!--				</div>-->
				<div class="nav_search">
					<form class="layui-form">
						<div class="layui-inline">
							<input class="layui-input" placeholder="会员编号/手机号/昵称筛选" name="keyword" value="<?php echo request()->param('keyword');?>"/>
						</div>

						<div class="layui-inline">
							<button class="layui-btn layuiadmin-btn-useradmin layui-btn-sm" lay-submit="" lay-filter="sreach">
								<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
							</button>
							{if $Request.param.keyword}
							<a href="{:url('relation/index')}" class="layui-btn layui-btn-danger layui-btn-sm">重置</a>
							{/if}
						</div>

					</form>
				</div>
			</div>
		</div>
		<div class="layui-card-body">

			{if $first}
			<div class="layui-tree layui-form layui-tree-line" lay-filter="LAY-tree-1">


				<div class="layui-tree-set layui-tree-spread layui-tree-setHide">
					<div class="layui-tree-entry opens" data-id="{$first.id}">
						<div class="layui-tree-main">
					<span class="layui-tree-iconClick layui-tree-icon">
						<i class="layui-icon layui-icon-addition"></i>
					</span>
							<span class="layui-tree-txt">{$first.title}</span>
						</div>
					</div>
					<div class="tp_{$first.id}">

					</div>
				</div>
			</div>
			{else}
			<h3 style="text-align: center">无数据</h3>
			{/if}
			<script id="template" type="text/html">
				{{# for(var i=0;i<d.length ;i++){ }}
				<div class="layui-tree-pack layui-tree-lineExtend layui-tree-showLine" style="display: block">
					<div class="layui-tree-set">
						<div class="layui-tree-entry opens" data-id="{{d[i].id}}" >
							<div class="layui-tree-main">
						<span class="layui-tree-iconClick layui-tree-icon">
							<i class="layui-icon layui-icon-addition"></i>
						</span>
								<span class="layui-tree-txt">{{d[i].title}}</span>
							</div>
						</div>
						<div class="tp_{{d[i].id}}">

						</div>
					</div>
				</div>
				{{# } }}
			</script>
		</div>

	</div>
</div>
</body>
{include file="public/footer" /}
<script>
	layui.use(['laytpl'], function () {

		var laytpl = layui.laytpl;

		$('.layui-tree').on('click', '.opens', function(){
			var obj = $(this);
			var id = obj.attr('data-id');
			var open = obj.find('i').hasClass('layui-icon-subtraction');
			if(open){
				$('.tp_'+id).html('');
				obj.find('i').removeClass('layui-icon-subtraction').addClass('layui-icon-addition');
				return false;
			}
			layer.load(2);
			$.ajax({
				type: 'GET',
				url: '{:url("getData")}',
				data:{id:id},
				dataType: "json",
				success: function (data) {
					layer.closeAll()
					var tpl = document.getElementById('template').innerHTML;
					laytpl(tpl).render(data.result, function (html) {
						$('.tp_'+id).html(html);
					});
					obj.find('i').removeClass('layui-icon-addition').addClass('layui-icon-subtraction');
				}
			});
		})
	});
</script>
</html>